//
// Created by cljh on 2023/3/28.
//

#ifndef BIN_PACKING_NFPUTILS_H
#define BIN_PACKING_NFPUTILS_H


#include "../entity/NestPath.h"
#include "../entity/NfpConfig.h"
#include "../utils/GeometryUtils.h"

class NfpUtils{
public:
    static NestPath nfpGenerator(NfpConfig nfpConfig){
        NestPath fixed=nfpConfig.fixed;
        NestPath orbited=nfpConfig.orbited;
        NfpKey key=nfpConfig.getKey();
        Polygon *polygonFixed=GeometryUtils::rotatePolygon(fixed[0],nfpConfig.key.aRotation);
        Polygon *polygonOrbited=GeometryUtils::rotatePolygon(orbited[0],nfpConfig.key.bRotation);
        NestPath nfpList=NestPath();
        if(nfpConfig.getKey().isInside()){
            nfpList=GeometryUtils::noFitPolygon(polygonFixed, polygonOrbited, true);
        } else{
            nfpList=GeometryUtils::noFitPolygon(polygonFixed, polygonOrbited, false);
        }
        delete polygonFixed;
        delete polygonOrbited;
        return nfpList;
    }
};



#endif //BIN_PACKING_NFPUTILS_H
